package com.xk.mybatis.mapper;

import com.xk.mybatis.entity.Emp;
import com.xk.mybatis.entity.User;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface UserMapper {

    //使用预编译#{...}



    //-- 删除id=17的数据
    @Delete("delete from emp where id=#{id}")
    public void deleteid(Integer id);


    //新增数据
        @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
                "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime});")
        public void insert(Emp emp);

    //主键返回插入
    @Options(useGeneratedKeys = true, keyProperty = "id")
    @Insert("insert into emp(username, name, gender, image, job, entrydate, dept_id, create_time, update_time)" +
            "values (#{username},#{name},#{gender},#{image},#{job},#{entrydate},#{deptId},#{createTime},#{updateTime});")
    public void insert1(Emp emp);

    //修改员工信息
    public void update(Emp emp);


    //根据ID查询
    @Select("select * from emp where id=#{id}")
    public Emp getEmpById(Integer id);
    //查询所有员工
    @Select("select * from emp")
    public List<Emp> getAllEmp();


    //查姓谢的
    public List<Emp> getEmpByName(String name);

    //批量查询
    List<Emp> getEmpByIds(@Param("ids") List[] ids);


}
